﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
                    xmlns:ex="using:Microsoft.Toolkit.Uwp.UI.Extensions"
                    xmlns:controls="using:Notepads.Controls">

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="SetsViewBackground" Color="Transparent"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundSelected"
                         Opacity="0.25"
                         Color="White"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPointerOver"
                         Opacity="0.15"
                         Color="White"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPressed"
                         Opacity="0.25"
                         Color="White"/>
            <StaticResource x:Key="SetsViewItemHeaderBackground"
                            ResourceKey="SystemControlTransparentBrush" />
            <StaticResource x:Key="SetsViewSelectionIndicatorForeground"
                            ResourceKey="SystemControlForegroundAccentBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForeground"
                            ResourceKey="SystemControlForegroundBaseMediumBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPressed"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundSelected"
                            ResourceKey="SystemControlForegroundBaseHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPointerOver"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundDisabled"
                            ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
            <StaticResource x:Key="SetsViewItemHeaderRevealBorderBrush"
                            ResourceKey="SystemControlBackgroundTransparentRevealBorderBrush" />
            <x:Double x:Key="SetsEdgeShadowOpacity">0.55</x:Double>
            <RevealBackgroundBrush x:Key="SetsViewItemRevealBackgroundBrush"
                                   Color="Gray"
                                   Opacity="0.3"
                                   FallbackColor="Gray" />
        </ResourceDictionary>

        <ResourceDictionary x:Key="Dark">
            <SolidColorBrush x:Key="SetsViewBackground" Color="Transparent"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundSelected"
                         Opacity="0.25"
                         Color="Black"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPointerOver"
                         Opacity="0.20"
                         Color="Black"/>
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPressed"
                         Opacity="0.25"
                         Color="Black"/>
            <StaticResource x:Key="SetsViewItemHeaderBackground"
                            ResourceKey="SystemControlTransparentBrush" />
            <StaticResource x:Key="SetsViewSelectionIndicatorForeground"
                            ResourceKey="SystemControlForegroundAccentBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForeground"
                            ResourceKey="SystemControlForegroundBaseMediumBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPressed"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundSelected"
                            ResourceKey="SystemControlForegroundBaseHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPointerOver"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundDisabled"
                            ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
            <StaticResource x:Key="SetsViewItemHeaderRevealBorderBrush"
                            ResourceKey="SystemControlBackgroundTransparentRevealBorderBrush" />
            <x:Double x:Key="SetsEdgeShadowOpacity">0.7</x:Double>
            <RevealBackgroundBrush x:Key="SetsViewItemRevealBackgroundBrush"
                                   Color="Transparent"
                                   FallbackColor="Transparent" />
        </ResourceDictionary>

        <ResourceDictionary x:Key="HighContrast">
            <SolidColorBrush x:Key="SetsViewBackground"
                             Color="{ThemeResource SystemChromeLowColor}" />
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundSelected"
                             Color="{ThemeResource SystemColorHighlightColor}" />
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPointerOver"
                             Color="{ThemeResource SystemColorHighlightColor}" />
            <SolidColorBrush x:Key="SetsViewItemHeaderBackgroundPressed"
                             Color="{ThemeResource SystemColorHighlightColor}" />
            <StaticResource x:Key="SetsViewItemHeaderBackground"
                            ResourceKey="SystemControlTransparentBrush" />
            <StaticResource x:Key="SetsViewSelectionIndicatorForeground"
                            ResourceKey="SystemControlForegroundAccentBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForeground"
                            ResourceKey="SystemControlForegroundBaseMediumBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPressed"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundSelected"
                            ResourceKey="SystemControlForegroundBaseHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundPointerOver"
                            ResourceKey="SystemControlForegroundBaseMediumHighBrush" />
            <StaticResource x:Key="SetsViewItemHeaderForegroundDisabled"
                            ResourceKey="SystemControlDisabledBaseMediumLowBrush" />
            <StaticResource x:Key="SetsViewItemHeaderRevealBorderBrush"
                            ResourceKey="SystemControlBackgroundTransparentRevealBorderBrush" />
            <x:Double x:Key="SetsEdgeShadowOpacity">0.0</x:Double>
            <SolidColorBrush x:Key="SetsViewItemRevealBackgroundBrush"
                             Color="Transparent" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <Thickness x:Key="SetsViewItemHeaderMargin">0</Thickness>
    <Thickness x:Key="SetsViewItemHeaderIconMargin">0,2,6,0</Thickness>
    <Thickness x:Key="SetsViewItemHeaderCloseMargin">0,1,0,0</Thickness>
    <Thickness x:Key="SetsViewItemHeaderBorderThickness">0,1,0,0</Thickness>
    <x:Double x:Key="SetsViewItemHeaderIconSize">10</x:Double>
    <x:Double x:Key="SetsViewItemHeaderMinWidth">48</x:Double>
    <x:Double x:Key="SetsViewItemHeaderMinHeight">40</x:Double>
    <x:Double x:Key="SetsViewItemHeaderMaxWidth">NaN</x:Double>
    <x:Double x:Key="SetsViewItemHeaderCloseWidth">24</x:Double>

    <converters:EmptyObjectToObjectConverter x:Key="NullVisibilityConverter"
                                             EmptyValue="Collapsed"
                                             NotEmptyValue="Visible" />
    <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />

    <!--  65 is the size of both scroll buttons + 1 for layout rounding.  -->
    <converters:DoubleToVisibilityConverter x:Key="GreaterThanToleranceVisibilityConverter"
                                            GreaterThan="65.0" />

    <converters:BoolToObjectConverter x:Key="CloseCollapsingSizeConverter"
                                      FalseValue="{StaticResource SetsViewItemHeaderCloseWidth}"
                                      TrueValue="NaN" />

    <Style x:Key="TopEdgeShadowStyle" TargetType="controls:DropShadowPanel">
        <Setter Property="BlurRadius" Value="10" />
        <Setter Property="ShadowOpacity" Value="{ThemeResource SetsEdgeShadowOpacity}" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>

    <Style x:Key="BottomEdgeShadowStyle" TargetType="controls:DropShadowPanel">
        <Setter Property="BlurRadius" Value="10" />
        <Setter Property="ShadowOpacity" Value="{ThemeResource SetsEdgeShadowOpacity}" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>

    <Style x:Key="SideEdgeShadowStyle" TargetType="controls:DropShadowPanel">
        <Setter Property="BlurRadius" Value="8" />
        <Setter Property="ShadowOpacity" Value="{ThemeResource SetsEdgeShadowOpacity}" />
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>

    <!--  Default style for compatibility with WPF migrators.  -->
    <Style TargetType="controls:SetsView">
        <Setter Property="Background" Value="{ThemeResource SetsViewBackground}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="TabNavigation" Value="Local" />
        <Setter Property="IsSwipeEnabled" Value="False" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled" />
        <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False" />
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
        <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="False" />
        <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True" />
        <!--  Need UseLayoutRounding as Width being dynamically changed in same cases to fill up an entire space, otherwise gap.  -->
        <Setter Property="UseLayoutRounding" Value="False" />
        <Setter Property="ItemContainerTransitions">
            <Setter.Value>
                <TransitionCollection>
                    <ContentThemeTransition />
                    <EntranceThemeTransition IsStaggeringEnabled="False" />
                    <EdgeUIThemeTransition Edge="Bottom" />
                </TransitionCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <!--  Note: We have to use StackPanel here due to other issues using ItemsStackPanel or VirtualizingStackPanel  -->
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template" Value="{StaticResource SetsViewTemplate}" />
    </Style>

    <ControlTemplate x:Key="SetsViewTemplate"
                     TargetType="controls:SetsView">
        <Grid x:Name="SetsViewContainer">
            <Grid.RowDefinitions>
                <!--  0 Header  -->
                <RowDefinition Height="Auto" />
                <!--  1 Sets  -->
                <RowDefinition Height="Auto" />
                <!--  2 Content  -->
                <RowDefinition Height="*" />
                <!--  3 Footer  -->
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <!--  0 SetsStartHeader  -->
                <ColumnDefinition Width="Auto" />
                <!--  1 Sets  -->
                <ColumnDefinition Width="Auto"
                                  controls:SetsView.ConstrainColumn="True"
                                  controls:SetsView.IgnoreColumn="True" />
                <!--  2 Reserved: Overflow Drop-down  -->
                <ColumnDefinition Width="Auto" />
                <!--  3 Auto Add Button  -->
                <ColumnDefinition Width="Auto" />
                <!--  4 Padding  -->
                <ColumnDefinition Width="*" 
                                  controls:SetsView.IgnoreColumn="True" />
                <!--  5 SetsEndHeader  -->
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ContentPresenter Grid.Row="0"
                              Grid.ColumnSpan="6"
                              Content="{TemplateBinding Header}"
                              ContentTemplate="{TemplateBinding HeaderTemplate}" />

            <!--  Shadow under Start Header  -->
            <controls:DropShadowPanel
                Style="{StaticResource BottomEdgeShadowStyle}"
                Grid.Row="1"
                Grid.Column="0">
                <Grid Height="1" Margin="0,0,0,-1"/>
                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="0,-12,1024,12"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>
            </controls:DropShadowPanel>

            <ContentPresenter Grid.Row="1"
                              Grid.Column="0"
                              Content="{TemplateBinding SetsStartHeader}"
                              ContentTemplate="{TemplateBinding SetsStartHeaderTemplate}" />

            <ScrollViewer x:Name="ScrollViewer"
                          Grid.Row="1"
                          Grid.Column="1"
                          BorderThickness="0"
                          AutomationProperties.AccessibilityView="Raw"
                          BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                          HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                          IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                          IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                          IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
                          IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                          IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
                          Style="{StaticResource SetsViewScrollViewer}"
                          TabNavigation="{TemplateBinding TabNavigation}"
                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                          VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                          ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
                <ItemsPresenter x:Name="SetsItemsPresenter"
                                Padding="{TemplateBinding Padding}" />
            </ScrollViewer>

            <!--  Shadow under Add Button  -->
            <controls:DropShadowPanel    
                Style="{StaticResource BottomEdgeShadowStyle}"
                Grid.Row="1"
                Grid.Column="3">
                <Grid Height="1" Margin="-1,0,0,-1"/>
                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="0,-12,1024,12"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>
            </controls:DropShadowPanel>

            <ContentPresenter Grid.Row="1"
                              Grid.Column="3"
                              HorizontalAlignment="Left"
                              Content="{TemplateBinding SetsActionHeader}"
                              ContentTemplate="{TemplateBinding SetsActionHeaderTemplate}" />

            <!--  Shadow under Padding area (23040 = 3 x 8k resolution in width just in case) -->
            <controls:DropShadowPanel    
                Style="{StaticResource BottomEdgeShadowStyle}"
                Grid.Row="1"
                Grid.Column="4">
                <Grid Height="1" Margin="0,0,0,-1"/>
                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="0,-12,23040,12"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>
            </controls:DropShadowPanel>

            <ContentPresenter Grid.Row="1"
                              Grid.Column="4"
                              HorizontalAlignment="Stretch"
                              Content="{TemplateBinding SetsPaddingHeader}"
                              ContentTemplate="{TemplateBinding SetsPaddingHeaderTemplate}" />

            <!--  Shadow under SetsEndHeader  -->
            <controls:DropShadowPanel
                Style="{StaticResource BottomEdgeShadowStyle}"
                Grid.Row="1"
                Grid.Column="5">
                <Grid Height="1" Margin="0,0,0,-1"/>
                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="0,-12,1024,12"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>
            </controls:DropShadowPanel>

            <ContentPresenter Grid.Row="1"
                              Grid.Column="5"
                              Content="{TemplateBinding SetsEndHeader}"
                              ContentTemplate="{TemplateBinding SetsEndHeaderTemplate}" />

            <ContentPresenter x:Name="SetsContentPresenter"
                              Canvas.ZIndex="100"
                              Grid.Row="2"
                              Grid.ColumnSpan="6" 
                              Grid.Column="0"
                              Background="{ThemeResource SetsViewItemHeaderBackgroundPressed}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}" />

            <!--  Shadow above Footer  -->
            <controls:DropShadowPanel    
                Style="{StaticResource TopEdgeShadowStyle}"
                Canvas.ZIndex="50"
                Grid.Row="3"
                Grid.ColumnSpan="6" 
                Grid.Column="0">
                <Grid Height="1"/>
                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="0,0,23040,12"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>
            </controls:DropShadowPanel>

            <ContentPresenter Grid.Row="3"
                              Canvas.ZIndex="50"
                              Grid.ColumnSpan="6" Grid.Column="0"
                              Content="{TemplateBinding Footer}"
                              ContentTemplate="{TemplateBinding FooterTemplate}" />
        </Grid>
    </ControlTemplate>

    <!--  Based on Style for ListViewItemExpanded Template - https://msdn.microsoft.com/en-us/library/windows/apps/mt299136.aspx  -->
    <ControlTemplate x:Key="SetsViewItemHeaderTemplate"
                     TargetType="controls:SetsViewItem">
        <Grid x:Name="LayoutRoot"
              ex:FrameworkElementExtensions.AncestorType="controls:SetsView"
              Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              Control.IsTemplateFocusTarget="True"
              FocusVisualMargin="{TemplateBinding FocusVisualMargin}"
              RenderTransformOrigin="0.5,0.5">
            <Grid.BackgroundTransition>
                <BrushTransition />
            </Grid.BackgroundTransition>
            <Grid.RenderTransform>
                <ScaleTransform x:Name="LayoutRootScale" />
            </Grid.RenderTransform>

            <controls:DropShadowPanel 
                x:Name="ItemLeftSideShadow"
                Style="{StaticResource SideEdgeShadowStyle}"
                HorizontalAlignment="Left">

                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="-8,0,8,32"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>

                <Grid Width="1"/>

            </controls:DropShadowPanel>

            <controls:DropShadowPanel 
                x:Name="ItemRightSideShadow"
                Style="{StaticResource SideEdgeShadowStyle}"
                HorizontalAlignment="Right">

                <controls:DropShadowPanel.Clip>
                    <RectangleGeometry Rect="1,0,8,32"></RectangleGeometry>
                </controls:DropShadowPanel.Clip>

                <Grid Width="1"/>

            </controls:DropShadowPanel>

            <controls:DropShadowPanel
                x:Name="ItemBottomSideShadow"
                Style="{StaticResource BottomEdgeShadowStyle}">
                <Grid Height="1"/>
            </controls:DropShadowPanel>

            <Rectangle x:Name="SelectionIndicator"
                       Height="2"
                       Margin="0,-1"
                       VerticalAlignment="Top"
                       Fill="{TemplateBinding SelectionIndicatorForeground}"
                       Opacity="0">
            </Rectangle>

            <Border x:Name="LeftSideSeparator"
                    Grid.Column="0"
                    HorizontalAlignment="Left"
                    Visibility="Collapsed"
                    Width="1"
                    BorderBrush="{ThemeResource SystemControlBackgroundBaseLowRevealBorderBrush}"
                    BorderThickness="1"
                    Margin="0,6,0,6"/>

            <Border x:Name="RightSideSeparator"
                    HorizontalAlignment="Right"
                    Visibility="Collapsed"
                    Width="1"
                    BorderBrush="{ThemeResource SystemControlBackgroundBaseLowRevealBorderBrush}"
                    BorderThickness="1"
                    Margin="0,6,0,6"/>

            <Grid Padding="{TemplateBinding Padding}">
                <Grid x:Name="ContentPresenterGrid">
                    <Grid.RenderTransform>
                        <TranslateTransform x:Name="ContentPresenterTranslateTransform" />
                    </Grid.RenderTransform>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <!--  Modifications of default ListViewItem Template for our Set Here  -->
                    <Viewbox x:Name="IconBox"
                             MaxWidth="{ThemeResource SetsViewItemHeaderIconSize}"
                             MaxHeight="{ThemeResource SetsViewItemHeaderIconSize}"
                             Margin="{ThemeResource SetsViewItemHeaderIconMargin}"
                             Visibility="{Binding Icon, Converter={StaticResource NullVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}">
                        <ContentPresenter x:Name="Icon"
                                          Content="{TemplateBinding Icon}"
                                          Foreground="{TemplateBinding Foreground}" />
                    </Viewbox>
                    <ContentPresenter x:Name="ContentPresenter"
                                      Grid.Column="1"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      Content="{TemplateBinding Header}"
                                      ContentTemplate="{TemplateBinding HeaderTemplate}"
                                      ContentTransitions="{TemplateBinding ContentTransitions}"
                                      FontWeight="{TemplateBinding FontWeight}"
                                      OpticalMarginAlignment="TrimSideBearings" />
                    <!--  Use grid to toggle visibility based on IsClosable property and inner border for hover animations.  -->
                    <Border x:Name="CloseButtonContainer"
                            Grid.Column="2"
                            Width="{Binding (ex:FrameworkElementExtensions.Ancestor).IsCloseButtonOverlay, Converter={StaticResource CloseCollapsingSizeConverter}, ElementName=LayoutRoot}"
                            HorizontalAlignment="Center"
                            Visibility="{Binding IsClosable, Converter={StaticResource BoolToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}">
                        <Border x:Name="CloseButtonBorder"
                                Width="{StaticResource SetsViewItemHeaderCloseWidth}"
                                Margin="{ThemeResource SetsViewItemHeaderCloseMargin}"
                                Background="{TemplateBinding Background}"
                                Visibility="Collapsed">
                            <Button x:Name="CloseButton"
                                    x:Uid="/SetsView/Resources/SetsView_CloseButton"
                                    Style="{StaticResource SetsViewItemCloseButtonStyle}">
                                &#xE711;
                            </Button>
                        </Border>
                    </Border>
                </Grid>
            </Grid>

            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal" />

                    <VisualState x:Name="PointerOver">
                        <VisualState.Setters>
                            <Setter Target="LayoutRoot.(RevealBrush.State)" Value="PointerOver" />
                            <Setter Target="LayoutRoot.Background" Value="{ThemeResource SetsViewItemRevealBackgroundBrush}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPointerOver}" />
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPointerOver}" />
                        </VisualState.Setters>

                        <Storyboard>
                            <!--  Close Button  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Background">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="Pressed">
                        <VisualState.Setters>
                            <Setter Target="LayoutRoot.(RevealBrush.State)" Value="Pressed" />
                            <Setter Target="LayoutRoot.Background" Value="{ThemeResource SetsViewItemRevealBackgroundBrush}" />
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPressed}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPressed}" />
                            <Setter Target="SelectionIndicator.Opacity" Value="0.4" />
                        </VisualState.Setters>
                    </VisualState>

                    <VisualState x:Name="Selected">
                        <VisualState.Setters>
                            <Setter Target="LayoutRoot.Background" Value="{ThemeResource SetsViewItemHeaderBackgroundSelected}" />
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundSelected}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundSelected}" />
                        </VisualState.Setters>

                        <Storyboard>
                            <!--  Selected Bar  -->
                            <DoubleAnimation Storyboard.TargetName="SelectionIndicator"
                                             Storyboard.TargetProperty="Opacity"
                                             To="1"
                                             Duration="0" />

                            <!--  Close Button  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Background">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>

                            <!--  Left, right and bottom shadows  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemLeftSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemRightSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemBottomSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Collapsed" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="PointerOverSelected">
                        <VisualState.Setters>
                            <Setter Target="LayoutRoot.Background" Value="{ThemeResource SetsViewItemHeaderBackgroundPointerOver}" />
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPointerOver}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPointerOver}" />
                        </VisualState.Setters>

                        <Storyboard>
                            <!--  Selected Bar  -->
                            <DoubleAnimation Storyboard.TargetName="SelectionIndicator"
                                             Storyboard.TargetProperty="Opacity"
                                             To="1"
                                             Duration="0" />

                            <!--  Close Button  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Background">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>

                            <!--  Left, right and bottom shadows  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemLeftSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemRightSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemBottomSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Collapsed" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="PressedSelected">
                        <VisualState.Setters>
                            <Setter Target="LayoutRoot.Background" Value="{ThemeResource SetsViewItemHeaderBackgroundSelected}" />
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPressed}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundPressed}" />
                        </VisualState.Setters>

                        <Storyboard>
                            <!--  Selected Bar  -->
                            <DoubleAnimation Storyboard.TargetName="SelectionIndicator"
                                             Storyboard.TargetProperty="Opacity"
                                             To="1"
                                             Duration="0" />

                            <!--  Close Button  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Background">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CloseButtonBorder"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>

                            <!--  Left, right and bottom shadows  -->
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemLeftSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemRightSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Visible" />
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemBottomSideShadow"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="Collapsed" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>

                <VisualStateGroup x:Name="DisabledStates">
                    <VisualState x:Name="Enabled" />

                    <VisualState x:Name="Disabled">
                        <VisualState.Setters>
                            <Setter Target="Icon.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundDisabled}" />
                            <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SetsViewItemHeaderForegroundDisabled}" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>

                <VisualStateGroup x:Name="DataVirtualizationStates">
                    <VisualState x:Name="DataAvailable" />

                    <VisualState x:Name="DataPlaceholder" />
                </VisualStateGroup>

                <VisualStateGroup x:Name="ReorderHintStates">
                    <VisualState x:Name="NoReorderHint" />

                    <VisualState x:Name="BottomReorderHint">
                        <Storyboard>
                            <DragOverThemeAnimation Direction="Bottom"
                                                    ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                                                    TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="TopReorderHint">
                        <Storyboard>
                            <DragOverThemeAnimation Direction="Top"
                                                    ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                                                    TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="RightReorderHint">
                        <Storyboard>
                            <DragOverThemeAnimation Direction="Right"
                                                    ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                                                    TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="LeftReorderHint">
                        <Storyboard>
                            <DragOverThemeAnimation Direction="Left"
                                                    ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                                                    TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0:0:0.2"
                                          To="NoReorderHint" />
                    </VisualStateGroup.Transitions>
                </VisualStateGroup>

                <VisualStateGroup x:Name="DragStates">
                    <VisualState x:Name="NotDragging" />

                    <VisualState x:Name="Dragging">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="Opacity"
                                             To="{ThemeResource ListViewItemDragThemeOpacity}"
                                             Duration="0" />
                            <DragItemThemeAnimation TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="DraggingTarget" />

                    <VisualState x:Name="MultipleDraggingPrimary" />

                    <VisualState x:Name="MultipleDraggingSecondary" />

                    <VisualState x:Name="DraggedPlaceholder" />

                    <VisualState x:Name="Reordering">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="Opacity"
                                             To="{ThemeResource ListViewItemReorderThemeOpacity}"
                                             Duration="0:0:0.240" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="ReorderingTarget">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot"
                                             Storyboard.TargetProperty="Opacity"
                                             To="{ThemeResource ListViewItemReorderTargetThemeOpacity}"
                                             Duration="0:0:0.240" />
                            <DoubleAnimation Storyboard.TargetName="LayoutRootScale"
                                             Storyboard.TargetProperty="ScaleX"
                                             To="{ThemeResource ListViewItemReorderTargetThemeScale}"
                                             Duration="0:0:0.240" />
                            <DoubleAnimation Storyboard.TargetName="LayoutRootScale"
                                             Storyboard.TargetProperty="ScaleY"
                                             To="{ThemeResource ListViewItemReorderTargetThemeScale}"
                                             Duration="0:0:0.240" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="MultipleReorderingPrimary" />

                    <VisualState x:Name="ReorderedPlaceholder">
                        <Storyboard>
                            <FadeOutThemeAnimation TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="DragOver">
                        <Storyboard>
                            <DropTargetItemThemeAnimation TargetName="LayoutRoot" />
                        </Storyboard>
                    </VisualState>

                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0:0:0.2"
                                          To="NotDragging" />
                    </VisualStateGroup.Transitions>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        </Grid>
    </ControlTemplate>

    <!--  Based on Style for Windows.UI.Xaml.Controls.ListViewItem  -->
    <Style TargetType="controls:SetsViewItem">
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="BorderBrush" Value="{ThemeResource SetsViewItemHeaderRevealBorderBrush}" />
        <Setter Property="BorderThickness" Value="{ThemeResource SetsViewItemHeaderBorderThickness}" />
        <Setter Property="Background" Value="{ThemeResource SetsViewItemHeaderBackground}" />
        <Setter Property="Foreground" Value="{ThemeResource SetsViewItemHeaderForeground}" />
        <Setter Property="Margin" Value="{ThemeResource SetsViewItemHeaderMargin}" />
        <Setter Property="TabNavigation" Value="Local" />
        <Setter Property="IsHoldingEnabled" Value="True" />
        <Setter Property="Padding" Value="8,0,4,0" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="MinWidth" Value="{ThemeResource SetsViewItemHeaderMinWidth}" />
        <Setter Property="MinHeight" Value="{ThemeResource SetsViewItemHeaderMinHeight}" />
        <Setter Property="MaxWidth" Value="{ThemeResource SetsViewItemHeaderMaxWidth}" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="FocusVisualMargin" Value="0" />
        <Setter Property="IsClosable" Value="False" />
        <Setter Property="SelectionIndicatorForeground" Value="{ThemeResource SetsViewSelectionIndicatorForeground}"/>
        <Setter Property="Template" Value="{StaticResource SetsViewItemHeaderTemplate}" />
    </Style>

    <Style x:Key="SetsViewItemCloseButtonStyle"
           TargetType="Button">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumHighBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Margin" Value="2,0,2,0" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid x:Name="RootGrid"
                          Background="{TemplateBinding Background}">
                        <ContentPresenter x:Name="ContentPresenter"
                                          Padding="{TemplateBinding Padding}"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                          AutomationProperties.AccessibilityView="Raw"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          BorderThickness="{TemplateBinding BorderThickness}"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="RootGrid" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource ButtonPointerOverForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <PointerUpThemeAnimation Storyboard.TargetName="RootGrid" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
                                                   Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}" />
                                        </ObjectAnimationUsingKeyFrames>-->
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource SystemControlHighlightBaseHighBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <PointerDownThemeAnimation Storyboard.TargetName="RootGrid" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource SystemControlBackgroundBaseLowBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="{ThemeResource SystemControlDisabledTransparentBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SetsViewRepeatButtonStyle" TargetType="RepeatButton">
        <Setter Property="Background" Value="{ThemeResource RepeatButtonRevealBackground}"/>
        <Setter Property="BackgroundSizing" Value="OuterBorderEdge"/>
        <Setter Property="Foreground" Value="{ThemeResource RepeatButtonForeground}"/>
        <Setter Property="BorderBrush" Value="{ThemeResource RepeatButtonRevealBorderBrush}"/>
        <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>
        <Setter Property="Padding" Value="{StaticResource ButtonPadding}"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
        <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
        <Setter Property="FocusVisualMargin" Value="-3"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BackgroundSizing="{TemplateBinding BackgroundSizing}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" CornerRadius="{TemplateBinding CornerRadius}" ContentTransitions="{TemplateBinding ContentTransitions}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonBackgroundPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonBorderBrushPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonForegroundPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonBackgroundPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonBorderBrushPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonForegroundPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HyperlinkButtonBackgroundDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonBorderBrushDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource RepeatButtonForegroundDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </ContentPresenter>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SetsViewScrollViewer"
           TargetType="ScrollViewer">
        <Setter Property="HorizontalScrollMode" Value="Auto" />
        <Setter Property="VerticalScrollMode" Value="Auto" />
        <Setter Property="IsHorizontalRailEnabled" Value="True" />
        <Setter Property="IsVerticalRailEnabled" Value="True" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="ZoomMode" Value="Disabled" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="VerticalScrollBarVisibility" Value="Visible" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="BorderThickness" Value="1,0,0,0" />
        <Setter Property="BorderBrush" Value="{ThemeResource SetsViewItemHeaderRevealBorderBrush}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border x:Name="Root"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <!--  Scroll to the left button bottom shadow  -->
                            <controls:DropShadowPanel
                                Style="{StaticResource BottomEdgeShadowStyle}"
                                Grid.Column="0">
                                <Grid Height="1" Margin="-1,0,0,-1"/>
                                <controls:DropShadowPanel.Clip>
                                    <RectangleGeometry Rect="-1,-12,1024,12"></RectangleGeometry>
                                </controls:DropShadowPanel.Clip>
                            </controls:DropShadowPanel>

                            <RepeatButton x:Name="SetsScrollBackButton"
                                          Grid.Column="0"
                                          VerticalAlignment="Stretch"
                                          Background="Transparent"
                                          BorderThickness="1"
                                          BorderBrush ="{ThemeResource SystemControlBackgroundTransparentRevealBorderBrush}"
                                          Delay="50"
                                          FontFamily="Segoe MDL2 Assets"
                                          Interval="100"
                                          Style="{ThemeResource SetsViewRepeatButtonStyle}"
                                          Visibility="{Binding ScrollableWidth, Converter={StaticResource GreaterThanToleranceVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=Collapsed, TargetNullValue=Collapsed}">
                                &#xE76B;
                            </RepeatButton>

                            <!--  SetsItemsScrollViewer left side shadow  -->
                            <controls:DropShadowPanel 
                                x:Name="SetsItemsScrollViewerLeftSideShadow"
                                Style="{StaticResource SideEdgeShadowStyle}"
                                Grid.Column="1" 
                                HorizontalAlignment="Left">
                                <Grid Width="1"/>
                                <controls:DropShadowPanel.Clip>
                                    <RectangleGeometry Rect="-10,0,10,32"></RectangleGeometry>
                                </controls:DropShadowPanel.Clip>
                            </controls:DropShadowPanel>

                            <!--  SetsItemsScrollViewer right side shadow  -->
                            <controls:DropShadowPanel 
                                x:Name="SetsItemsScrollViewerRightSideShadow"
                                Style="{StaticResource SideEdgeShadowStyle}"
                                Grid.Column="1" 
                                HorizontalAlignment="Right">
                                <Grid Width="1"/>
                                <controls:DropShadowPanel.Clip>
                                    <RectangleGeometry Rect="1,0,10,32"></RectangleGeometry>
                                </controls:DropShadowPanel.Clip>
                            </controls:DropShadowPanel>

                            <ScrollContentPresenter x:Name="ScrollContentPresenter"
                                                    Grid.Column="1"
                                                    TabFocusNavigation="Once"
                                                    Margin="{TemplateBinding Padding}"/>

                            <!--  Scroll to the right button bottom shadow  -->
                            <controls:DropShadowPanel
                                Style="{StaticResource BottomEdgeShadowStyle}"
                                Grid.Column="2">
                                <Grid Height="1" Margin="0,0,0,-1"/>
                                <controls:DropShadowPanel.Clip>
                                    <RectangleGeometry Rect="0,-12,1024,12"></RectangleGeometry>
                                </controls:DropShadowPanel.Clip>
                            </controls:DropShadowPanel>

                            <RepeatButton x:Name="SetsScrollForwardButton"
                                          Grid.Column="2"
                                          VerticalAlignment="Stretch"
                                          Background="Transparent"
                                          BorderThickness="1"
                                          BorderBrush ="{ThemeResource SystemControlBackgroundTransparentRevealBorderBrush}"
                                          Delay="50"
                                          FontFamily="Segoe MDL2 Assets"
                                          Interval="100"
                                          Style="{ThemeResource SetsViewRepeatButtonStyle}"
                                          Visibility="{Binding ScrollableWidth, Converter={StaticResource GreaterThanToleranceVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=Collapsed, TargetNullValue=Collapsed}">
                                &#xE76C;
                            </RepeatButton>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
